﻿
SET QUOTED_IDENTIFIER ON
GO

SET ANSI_NULLS ON
GO

IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[sproc_SMS_ReadMsg_V2]') AND type in (N'P', N'PC'))
    DROP PROCEDURE [dbo].[sproc_SMS_ReadMsg_V2];
GO
CREATE PROCEDURE [dbo].[sproc_SMS_ReadMsg_V2]
    @msgIds		xml,
    @username	nvarchar(50)
/*

============================================================
功能:    Mark the specified messages as read
参数:
    @msgids                     xml    :    消息ID字符串
    @username                     nvarchar,    :    用户名

============================================================

*/
AS
BEGIN
SET NOCOUNT ON;

/*
 * XML format:
 * <messages>
 *  <m id="" />
 * </messages>
 */

UPDATE R
SET R.IsRead = 1
FROM dbo.UDS_SMS_Receiver R INNER JOIN @msgIds.nodes(N'/messages/m') X(m) ON R.MsgId = X.m.value(N'@id', 'int');

END
GO
